From: Claudio Cambra Date: Wed, 22 Mar 2023 13:50:48 +0000 (+0100) Subject: Use AccountPtr in pushNotificationsReady signal in Account rather than raw pointer X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2^2~26^2~6 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22Program/%22http:/www.example.com/cgi/%22https:/%22Program?a=commitdiff_plain;h=536b032a03749bdb4211f1d72289ddd02a2137e6;p=nextcloud-desktop.git Use AccountPtr in pushNotificationsReady signal in Account rather than raw pointer Signed-off-by: Claudio Cambra --- diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp index 892c4fef0..5ee0737e2 100644 --- a/src/gui/folderman.cpp +++ b/src/gui/folderman.cpp @@ -982,7 +982,7 @@ void FolderMan::slotStartScheduledFolderSync() } } -bool FolderMan::pushNotificationsFilesReady(Account *account) +bool FolderMan::pushNotificationsFilesReady(const AccountPtr &account) { const auto pushNotifications = account->pushNotifications(); const auto pushFilesAvailable = account->capabilities().availablePushNotifications() & PushNotificationType::Files; @@ -1017,7 +1017,7 @@ void FolderMan::slotEtagPollTimerTimeout() // Some folders need not to be checked because they use the push notifications std::copy_if(folderMapValues.begin(), folderMapValues.end(), std::back_inserter(foldersToRun), [this](Folder *folder) -> bool { const auto account = folder->accountState()->account(); - return !pushNotificationsFilesReady(account.data()); + return !pushNotificationsFilesReady(account); }); qCInfo(lcFolderMan) << "Number of folders that don't use push notifications:" << foldersToRun.size(); @@ -1059,7 +1059,7 @@ void FolderMan::runEtagJobIfPossible(Folder *folder) return; } // When not using push notifications, make sure polltime is reached - if (!pushNotificationsFilesReady(folder->accountState()->account().data())) { + if (!pushNotificationsFilesReady(folder->accountState()->account())) { if (folder->msecSinceLastSync() < polltime) { qCInfo(lcFolderMan) << "Can not run etag job: Polltime not reached"; return; @@ -2059,7 +2059,7 @@ void FolderMan::slotSetupPushNotifications(const Folder::Map &folderMap) // See if the account already provides the PushNotifications object and if yes connect to it. // If we can't connect at this point, the signals will be connected in slotPushNotificationsReady() // after the PushNotification object emitted the ready signal - slotConnectToPushNotifications(account.data()); + slotConnectToPushNotifications(account); connect(account.data(), &Account::pushNotificationsReady, this, &FolderMan::slotConnectToPushNotifications, Qt::UniqueConnection); } } @@ -2079,7 +2079,7 @@ void FolderMan::slotProcessFilesPushNotification(Account *account) } } -void FolderMan::slotConnectToPushNotifications(Account *account) +void FolderMan::slotConnectToPushNotifications(const AccountPtr &account) { const auto pushNotifications = account->pushNotifications(); diff --git a/src/gui/folderman.h b/src/gui/folderman.h index 9ab08c9ab..4c33005bb 100644 --- a/src/gui/folderman.h +++ b/src/gui/folderman.h @@ -337,7 +337,7 @@ private slots: void slotSetupPushNotifications(const OCC::Folder::Map &); void slotProcessFilesPushNotification(OCC::Account *account); - void slotConnectToPushNotifications(OCC::Account *account); + void slotConnectToPushNotifications(const OCC::AccountPtr &account); void slotLeaveShare(const QString &localFile, const QByteArray &folderToken = {}); @@ -369,7 +369,7 @@ private: void runEtagJobsIfPossible(const QList &folderMap); void runEtagJobIfPossible(Folder *folder); - bool pushNotificationsFilesReady(Account *account); + bool pushNotificationsFilesReady(const OCC::AccountPtr &account); [[nodiscard]] bool isSwitchToVfsNeeded(const FolderDefinition &folderDefinition) const; diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index fc7af4d1e..cf59af7d5 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -332,7 +332,7 @@ void Account::trySetupPushNotifications() connect(_pushNotifications, &PushNotifications::ready, this, [this]() { _pushNotificationsReconnectTimer.stop(); - emit pushNotificationsReady(this); + emit pushNotificationsReady(sharedFromThis()); }); const auto disablePushNotifications = [this]() { diff --git a/src/libsync/account.h b/src/libsync/account.h index 49d9d20e5..ae119758f 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -460,7 +460,7 @@ signals: /// Used in RemoteWipe void appPasswordRetrieved(QString); - void pushNotificationsReady(OCC::Account *account); + void pushNotificationsReady(const OCC::AccountPtr &account); void pushNotificationsDisabled(OCC::Account *account); void userStatusChanged();